// pages/personal/bind-mobile.js
const app = getApp()
Page({

    data: {},

    onLoad: function() {
        wx.login({
            success: res => {
                this.code = res.code
            }
        })
    },
    //授权
    getPhoneNumber(e) {
        if (e.detail.errMsg == 'getPhoneNumber:ok') {
            app.http.post('authorize/get-phone', {
                header: {
                    "Code": this.code,
                    "Encrypted-Data": e.detail.encryptedData,
                    "IV": e.detail.iv
                }
            }).then(res => {
                if (res.data) {
                    wx.showToast({
                        icon: 'none',
                        title: '已完成绑定',
                        success: res => {
                            wx.navigateBack({
                                delta: 1
                            })
                        }
                    })

                }
            })
        }
    },
    toMobileCode: function() {
        wx.navigateTo({
            url: '/pages/personal/mobile-input',
        })
    },

})